/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bankowosc.polaczenie;

import bankowosc.dane.Status;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author Maciek
 */
public class StatusDB {
    public Status  pobierz_status(polacz p, String id) {
		Status  stat= new Status();
		Statement stmt = p.getStmt();
		String komenda = "select * from Status where ID_Statusu="+id;
		try {
                       
			ResultSet rs = stmt.executeQuery(komenda);
			while(rs.next()) {
				stat= new Status (rs.getInt(1),rs.getString(2));
			}
			rs.close();
			return stat;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
    
    public ArrayList<Status> pobierzStatusy(polacz p) {
    	ArrayList<Status> statusy = new ArrayList<>();
    	Statement stmt = p.getStmt();
    	String komenda = "select * from status";
    	try {
			ResultSet rs = stmt.executeQuery(komenda);
			while(rs.next()) {
				statusy.add(new Status(rs.getInt(1),rs.getString(2)));
			}
			rs.close();
			return statusy;
		} catch (SQLException e) {
			e.printStackTrace();
		}
    	return null;
    }
}
